﻿using CommandSet.utils;
using System;
using System.Collections.Generic;
using System.IO;
using System.Windows.Forms;
using WindowsImageCompressionApp.utils;

namespace VmixTranslationTool
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }



        private void Form1_Load(object sender, EventArgs e)
        {

            checkIfTheDirectoryExists();








        }

        private void checkIfTheDirectoryExists()
        {
            string default_root_directory = @"C:\Program Files (x86)\vMix\";
            string default_zh = Path.Combine(default_root_directory, "languages", "zh.txt");
            string run_path = Environment.CurrentDirectory;

            if (Directory.Exists(default_root_directory))
            {
               
                label2.Text = default_root_directory;

                if (File.Exists(default_zh))
                {
                    label4.Text = default_zh;
                }
                else
                {
                    label2.Text = "vmix汉化文件获取失败，请手动选择";
                }
            }
            else
            {
                label2.Text = "vmix安装路径获取失败，请手动选择";
                label4.Text = "vmix安装路径获取失败，请手动选择";
            }


        }



        private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            DBUtil.openLink("http://801.mdhyy.cn/");
        }

        private void menuItem2_Click(object sender, EventArgs e)
        {

            string dir = "";
            Dictionary<string, string> net_files = new Dictionary<string, string>();

            net_files.Add("net_mdhyy_vmix27_language.config", "");
   
            foreach (var item in net_files)
            {
                NetUtil.downloadFile(item.Value, item.Value);
            }

        }

        private void button1_Click(object sender, EventArgs e)
        {
            //终止进程先



        }

        private void button2_Click(object sender, EventArgs e)
        {

            FolderBrowserDialog dialog = new FolderBrowserDialog
            {
                SelectedPath = "C:" // 设置初始路径
                ,Description = "请选择vmix安装目录"
            };
            if (dialog.ShowDialog() == DialogResult.OK)
            {
                // 用户选择了文件夹，可以在这里进行相关操作
            }
        }
    }
}
